package com.igeek.javase.ch04.gameTest;

/*
 *@author wangpeng
 *2023/7/13 19:31
 *@description TODO
 */

/*
* 2、定义一个怪兽类Monster，可以通过这个类创建各种怪兽，
怪兽拥有名称name，等级level，血量blood，攻击力power，防御力defence，种族kind。
怪兽拥有基本攻击方法attack(Hero h)，死亡判定方法isDead()，获取怪兽信息的方法show()。
* */
public class Monster extends Role {

    //基本攻击方法

    @Override
    public void attack(Role h) {
        int blood = super.getPower() - h.getDefence();
        if (blood >= 0) {
            h.setBlood(h.getBlood() - blood);
            System.out.println("当前英雄本回合失血量：" + blood + "，剩余血量：" + h.getBlood());
        } else {
            System.out.println("此回合攻击无效！");
        }
    }


    //死亡判定方法

    @Override
    public boolean isDead() {
        if (super.getBlood() <= 0) {
            System.out.println("当前怪兽已死亡！");
            return true;
        }
        return false;
    }

    //获取怪兽信息的方法
    public void show() {
        System.out.println("怪兽的昵称：" + super.getNickName());
        System.out.println("怪兽的等级：" + super.getLevel());
        System.out.println("怪兽的血量：" +super.getBlood());
        System.out.println("怪兽的攻击力：" + super.getPower());
        System.out.println("怪兽的防御力：" + super.getDefence());
        System.out.println("怪兽的类别：" + super.getKind());
    }

    public Monster() {
    }

    public Monster(String nickName, int level, int blood, int power, int defence, String kind) {
        super(nickName, level, blood, power, defence, kind);
    }

    public String toString() {
        return "Monster{nickName = " + super.getNickName() + ", level = " + super.getLevel() + ", blood = " + super.getBlood() + ", power = " + super.getPower() + ", defence = " + super.getDefence() + ", kind = " + super.getKind() + "}";
    }
}
